home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8411.arc / AUTOTEST.C < prev    next >
Text File  |  1986-09-14  |  2KB  |  81 lines

  1. /* disktest.c - test raw disk i/O */
  2. #include "stdio.h"
  3. #include "ctype.h"
  4.  
  5. #define ASIZE  25000        /* size of area for a buffer */
  6.  
  7. long seqio() , randio() ;
  8. char *align() ;
  9. int dno , nstart , i , nit ;
  10. char *pbuf ;
  11.  
  12. int clu , free , tot , bps ;    /* disk space variables */
  13. long totsec ;            /* put total sectors here */
  14.  
  15. main(argc,argv)
  16.  int argc ;
  17.  char *argv[] ;
  18.  {
  19.     char area[ ASIZE ] ;
  20.  
  21.     /* ensure that the buffer does not cross a 64K address boundary */
  22.     pbuf = align(area,ASIZE/2) ;  
  23.  
  24.     printf(" drive number (0=a , 1=b ...) \n") ;
  25.     scanf("%d",&dno) ;
  26.  
  27.     clu = getspac(dno+1,&free,&tot,&bps) ;
  28.     if( clu == 0xffff )
  29.       { printf(" invalid drive number \n");
  30.         exit(10) ;
  31.       }
  32.     totsec = clu * (long) tot ;
  33.     printf(" total number of sectors = %ld \n",totsec) ;
  34.  
  35.     nstart = 0 ;  nit = 20 ;
  36.     printf(" Sequential Reads \n");
  37.     doseq(1) ;            /* run some Sequential Read tests*/
  38.     doseq(8) ;
  39.     doseq(16) ;
  40.     doseq(24) ;
  41.                 /* now run some random read tests */
  42.     nit = 40 ;
  43.     printf(" Random Reads - %2d sector \n",1);
  44.     dorand(1, 0.1 ) ;
  45.     dorand(1, 0.33 ) ;
  46.     dorand(1, 0.5 ) ;
  47.     dorand(1, 0.9 ) ;
  48.     printf(" Random Reads - %2d sector \n",8);
  49.     nit = 20 ;
  50.     dorand(8, 0.1 ) ;
  51.     dorand(8, 0.33 ) ;
  52.     dorand(8, 0.5 ) ;
  53.     dorand(8, 0.9 ) ;
  54.  }
  55.  
  56. int doseq(nseg)
  57.  int nseg ;
  58.  {
  59.    long t ;
  60.  
  61.    t = seqio(dno,nseg,nstart,pbuf,nit) ;
  62.    printf(" %2d sectors          - ", nseg ) ;
  63.    printf("  %4.3f Sec/read \n",  t / (18.2*nit) ) ;
  64.  }
  65.  
  66.  
  67.  
  68. int dorand(nseg,frac)
  69.  int nseg ;
  70.  float frac ;
  71.  {
  72.    long t ;
  73.    int offset ;
  74.  
  75.    offset = totsec * frac ;
  76.    t = randio(dno,nseg,nstart,pbuf,nit,offset) ;
  77.    printf(" %5.2f width seeks   - ", frac) ;
  78.    printf("  %4.3f Sec/read \n",  t / (18.2*nit) ) ;
  79.  }
  80.    
  81.